-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1103 Improve arrow function #1112
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #1112 +/- ##
==========================================
- Coverage 88.45% 88.42% -0.04%
==========================================
Files 116 117 +1
Lines 8611 8653 +42
==========================================
+ Hits 7617 7651 +34
- Misses 994 1002 +8 ☔ View full report in Codecov by Sentry. |
@dantownsend It seems that when we use the arrow function we need def test_arrow_where(self):
"""
Make sure the arrow function can be used within a WHERE clause.
"""
RecordingStudio(
name="Abbey Road", facilities='{"mixing_desk": true}'
).save().run_sync()
self.assertEqual(
RecordingStudio.count()
.where(RecordingStudio.facilities.arrow("mixing_desk").eq("true")) # <-- here
.run_sync(),
1,
)
self.assertEqual(
RecordingStudio.count()
.where(RecordingStudio.facilities.arrow("mixing_desk").eq("false")) # <-- here
.run_sync(),
0,
) I also removed the load json test because the I hope that makes sense. |
@sinisaos Thanks - you're right, the JSON values have to be strings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dantownsend I think this is a great enhancement 👍
@sinisaos Thanks. I went a bit crazy on this in the end. You can now go multiple levels deep, and traverse array elements within the JSON. await RecordingStudio.select(
RecordingStudio.facilities["a"]["b"][0]["c"]
) |
@dantownsend Wow! It's really amazing. |
@sinisaos Thanks. It turned into a bigger thing than I expected. But with this, we can potentially do better JSON filtering in Piccolo Admin. |
Resolves #1103